package com.ruoyi.evaluate.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.evaluate.domain.EvaluateNorm;
import com.ruoyi.evaluate.service.IEvaluateNormService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 评价指标Controller
 * 
 * @author yepanpan
 * @date 2020-11-09
 */
@Api("评价指标信息管理")
@RestController
@RequestMapping("/evaluate/evalNorm")
public class EvaluateNormController extends BaseController
{
    @Autowired
    private IEvaluateNormService evaluateNormService;

    /**
     * 查询评价指标列表
     */
    @ApiOperation("获取评价指标列表")
    @GetMapping("/list")
    public AjaxResult list(EvaluateNorm evaluateNorm)
    {
        List<EvaluateNorm> list = evaluateNormService.selectEvaluateNormList(evaluateNorm);
        return AjaxResult.success(list);
    }
    
    /**
     * 查询评价指标列表
     */
    @ApiOperation("获取评价指标列表")
    @GetMapping("/select")
    public AjaxResult select(EvaluateNorm evaluateNorm)
    {
        List<EvaluateNorm> list = evaluateNormService.selectEvaluateNormList(evaluateNorm);
        return AjaxResult.success(list);
    }

    /**
     * 导出评价指标列表
     */
    @ApiOperation("导出评价指标列表")
    @PreAuthorize("@ss.hasPermi('evaluate:evalNorm:export')")
    @Log(title = "评价指标", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EvaluateNorm evaluateNorm)
    {
        List<EvaluateNorm> list = evaluateNormService.selectEvaluateNormList(evaluateNorm);
        ExcelUtil<EvaluateNorm> util = new ExcelUtil<EvaluateNorm>(EvaluateNorm.class);
        return util.exportExcel(list, "evalNorm");
    }

    /**
     * 获取评价指标详细信息
     */
    @ApiOperation("获取评价指标详细信息")
    @ApiImplicitParam(name = "id", value = "评价指标ID", required = true, dataType = "int", paramType = "path")
    @PreAuthorize("@ss.hasPermi('evaluate:evalNorm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(evaluateNormService.selectEvaluateNormById(id));
    }

    /**
     * 新增评价指标
     */
    @ApiOperation("新增评价指标")
    @PreAuthorize("@ss.hasPermi('evaluate:evalNorm:add')")
    @Log(title = "评价指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvaluateNorm evaluateNorm)
    {
        return toAjax(evaluateNormService.insertEvaluateNorm(evaluateNorm));
    }

    /**
     * 修改评价指标
     */
    @ApiOperation("修改评价指标")
    @PreAuthorize("@ss.hasPermi('evaluate:evalNorm:edit')")
    @Log(title = "评价指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvaluateNorm evaluateNorm)
    {
        return toAjax(evaluateNormService.updateEvaluateNorm(evaluateNorm));
    }

    /**
     * 删除评价指标
     */
    @ApiOperation("删除评价指标")
    @ApiImplicitParam(name = "id", value = "评价指标ID", required = true, dataType = "int", paramType = "path")
    @PreAuthorize("@ss.hasPermi('evaluate:evalNorm:remove')")
    @Log(title = "评价指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(evaluateNormService.deleteEvaluateNormByIds(ids));
    }
}
